package ru.bytedog.oiot.counter.bot.service.adapter;

import com.google.gson.JsonPrimitive;
import org.junit.jupiter.api.Test;

import java.time.LocalDate;
import java.time.LocalDateTime;

import static org.junit.jupiter.api.Assertions.*;

class LocalDateTimeAdapterTest {

    private static final LocalDateTime LOCAL_DATE_TIME = LocalDate.of(2020, 3, 12).atStartOfDay();
    private final LocalDateTimeAdapter adapter = new LocalDateTimeAdapter();

    @Test
    void deserialize() {
        assertEquals(LOCAL_DATE_TIME, adapter.deserialize(new JsonPrimitive("2020-03-12 00:00:00"), null, null));
        assertNull(adapter.deserialize(null, null, null));
        assertNull(adapter.deserialize(new JsonPrimitive(""), null, null));
    }

    @Test
    void serialize() {
        assertEquals(new JsonPrimitive("12 марта 00:00"), adapter.serialize(LOCAL_DATE_TIME, null, null));
        assertNull(adapter.serialize(null, null, null));
    }
}